package gov.tax.rti.ext.bdf2.utils;

import gov.tax.rti.core.startup.RtiPropertyHolder;
import gov.tax.rti.core.util.RtiConfigure;

import org.apache.commons.lang.StringUtils;

import com.bstek.bdf2.core.orm.IDao;
import com.bstek.dorado.core.Configure;

public class CompanyIdUtil {
	
	public static final String PROPERTY_BDF2_COMPANYID = "rti.bdf2.companyId";
	public static final String PROPERTY_JOB_COMPANYID_DEFAULT = "RTI";
	
	public static String getCompanyId() {
		String companyId = Configure.getString(PROPERTY_BDF2_COMPANYID);
		if(companyId == null){
			companyId = RtiConfigure.getString(PROPERTY_BDF2_COMPANYID, Configure.getString(IDao.FIXED_COMPANY_ID));
			if(StringUtils.isEmpty(companyId)){
				companyId = Configure.getString(RtiPropertyHolder.PROPERTY_APPNAME, RtiConfigure.getString(RtiPropertyHolder.PROPERTY_APPNAME, PROPERTY_JOB_COMPANYID_DEFAULT));
			}
			Configure.getStore().set(PROPERTY_BDF2_COMPANYID, companyId);
		}
		return companyId;
	}

}
